var Ball = function () {
  var b = {
    width: 20,
    height: 20,
    x: 200,
    y: 200,
    speedX: 3,
    speedY: 4,

    fired: false
  };

  b.fire = function fire() {
    b.fired = true
  }

  b.move = function () {
    if (b.fired) {
      if (b.x <= 0 || b.x + b.width >= 600) {
        b.speedX *= -1
      }
      if (b.y <= 0 || b.y + b.height >= 600) {
        b.speedY *= -1
      }
      // move
      b.x += b.speedX
      b.y += b.speedY
    }

    // log(b)

  }

  b.hasPoint = function (x, y) {
    var inX = x > b.x && x < b.x + b.width
    var inY = y > b.y && y < b.y + b.height
    return inX && inY
  }

  b.setPosition = function (x, y) {
    b.x = x
    b.y = y
  }

  return b;
}
